//
//  BK_Calendar_HeaderView.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/2/28.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_Calendar_HeaderView.h"



#import "BK_OD_Color.h"



/**
 calendar header view
 */
@implementation BK_Calendar_HeaderView
{
    UILabel *_titleLab;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initialize];
        
    }
    return self;
}

- (void)initialize
{
    _formatter = [[NSDateFormatter alloc] init];
    [_formatter setDateFormat:@"yyyy年M月"];
    
    _titleLab = [[UILabel alloc] init];
    _titleLab.textColor = kOrderBlack2;
    _titleLab.font = [UIFont systemFontOfSize:15];
    _titleLab.textAlignment = NSTextAlignmentCenter;
    _titleLab.numberOfLines = 1;
    [self addSubview:_titleLab];
    [self makeConstraints];
}

- (void)makeConstraints
{
    _titleLab.translatesAutoresizingMaskIntoConstraints = NO;
    NSLayoutConstraint *titleLabTopConstraint = [NSLayoutConstraint constraintWithItem:_titleLab attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1 constant:0];
    NSLayoutConstraint *titleLabLeftConstraint = [NSLayoutConstraint constraintWithItem:_titleLab attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
    NSLayoutConstraint *titleLabRightConstraint = [NSLayoutConstraint constraintWithItem:_titleLab attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1 constant:0];
    NSLayoutConstraint *titleLabBottomConstraint = [NSLayoutConstraint constraintWithItem:_titleLab attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
    
    [self addConstraints:@[titleLabTopConstraint, titleLabLeftConstraint, titleLabBottomConstraint, titleLabRightConstraint]];
}

- (void)setTitle:(NSString *)title
{
    _titleLab.text = title;
}

@end
